package com.heu.blood.bag.controller;

import java.util.Arrays;
import java.util.Map;


import com.heu.blood.bag.vo.BloodBagRecycleAddVo;
import com.heu.blood.bag.vo.BloodBagRecycleSelectVo;
import com.heu.blood.common.aop.ControllerLogAnnotation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.heu.blood.bag.entity.BloodBagNewRecycleEntity;
import com.heu.blood.bag.service.BloodBagNewRecycleService;

import com.heu.blood.common.utils.PageUtils;
import com.heu.blood.common.utils.R;




/**
 * 
 *
 * @author lyj
 * @email lyj@heu.com
 * @date 2025-01-15 20:36:11
 */
@RestController
@RequestMapping("bag/bloodbagnewrecycle")
public class BloodBagRecycleNewController {
    @Autowired
    private BloodBagNewRecycleService bloodBagRecycleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bloodBagRecycleService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		BloodBagNewRecycleEntity bloodBagRecycle = bloodBagRecycleService.getById(id);

        return R.ok().put("bloodBagRecycle", bloodBagRecycle);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BloodBagNewRecycleEntity bloodBagRecycle){
		bloodBagRecycleService.save(bloodBagRecycle);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BloodBagNewRecycleEntity bloodBagRecycle){
		bloodBagRecycleService.updateById(bloodBagRecycle);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		bloodBagRecycleService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    @RequestMapping("/bloodBagList")
    @ControllerLogAnnotation(module = "血袋回收模块", operate = "查询血袋回收信息")
    public R bloodBagList(@RequestBody BloodBagRecycleSelectVo bloodBagRecycleSelectVo){
        PageUtils page = bloodBagRecycleService.bloodBagList(bloodBagRecycleSelectVo);

        return R.ok().put("page", page);
    }

    @RequestMapping("/bloodBagQuickAdd")
    @ControllerLogAnnotation(module = "血袋回收模块", operate = "快捷添加血袋回收信息")
    public R bloodBagQuickAdd(@RequestBody BloodBagRecycleAddVo bloodBagRecycleAddVo){
        int insert = bloodBagRecycleService.bloodBagQuickAdd(bloodBagRecycleAddVo);
        if (insert == 1) {
            return R.ok("插入成功");
        }else{
            return R.ok("插入失败");
        }
    }

    @RequestMapping("/bloodBagSlowAdd")
    @ControllerLogAnnotation(module = "血袋回收模块", operate = "手动添加血袋回收信息")
    public R bloodBagSlowAdd(@RequestBody BloodBagNewRecycleEntity bloodBagRecycle){
        int insert = bloodBagRecycleService.bloodBagSlowAdd(bloodBagRecycle);
        if (insert == 1) {
            return R.ok("插入成功");
        }else{
            return R.ok("插入失败");
        }
    }


}
